package com.dlc.felear.xiaoensale.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Eric Deng on 2018/9/4
 */

public class TimeUtils {

    /**
     * 获取时间 小时:分;秒 HH:mm:ss
     *
     * @return
     */
    public static String getCurrrentTimeYMDHMS() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date currentTime = new Date();
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    public static String getTimeYMDHMS(long date) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date currentTime = new Date(date);
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    public static long getDateToLong(String date) {
        long temp = 0;
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            temp = formatter.parse(date).getTime();
        } catch (Exception e) {
            temp = -1;
        }
        return temp;
    }

    /**
     * 获取时间 小时:分;秒 HH:mm:ss
     *
     * @return
     */
    public static String getCurrrentTimeHMS() {
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        Date currentTime = new Date();
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    /**
     * 获取时间 小时:分;秒 HH:mm:ss
     *
     * @return
     */
    public static String getCurrrentTimeYMD() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date currentTime = new Date();
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    /**
     * 获取时间
     *
     * @return
     */
    public static long getCurrrentTime() {
        return new Date().getTime();
    }

    public static long getHourTimestamp(int hour) {
        long timestamp = System.currentTimeMillis();
        String tt = getCurrrentTimeHMS();
        try {
            Date date = new Date();
            date.setTime(System.currentTimeMillis());
            date.setHours(hour);
            timestamp = date.getTime();
        } catch (Exception e) {

        }
        return timestamp;
    }

    public static void printTime(long timestamp) {

    }

}
